package com.intco.ait.quotation.api.common.model.pojo;

import com.alibaba.fastjson2.JSON;
import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Material base data with default values populated from baseinfo.yml.
 * Kebab-case keys in YAML are mapped to camelCase field names here.
 */
@Data
public class MaterialBaseData {
    public Finished finished = new Finished();
    public Building building = new Building();
    public Frame frame = new Frame();
    public Pellet pellet = new Pellet();
    public Other other = new Other();

    // ================= Finished =================
    @Data
    public static class Finished {
        public String csaComUnitCode = "J00"; // 辅计量单位 箱单位
        public String pkMeasdoc = "J11";      // 主计量单位 片单位
        public MouldData mouldData = new MouldData();
        public Currency currency = new Currency();
        public List<Feature> features = buildFeatures();
        public List<DataExchangeConfig> dataExchangeConfig = buildCommonExchangeConfig();
    }

    @Data
    public static class MouldData {
        public List<String> mouldTypeList = new ArrayList<>(Arrays.asList(
                "外框", "内框", "嵌条", "撑脚", "其他"
        ));
        public List<ValueName> cuttingModeList = new ArrayList<>(Arrays.asList(
                new ValueName("1", "横切"),
                new ValueName("2", "竖切"),
                new ValueName("3", "其他")
        ));
    }


    @Data
    public static class Currency {
        public List<ValueName> qualityList = new ArrayList<>(Arrays.asList(
                new ValueName("1", "PS"), new ValueName("2", "MDF"), new ValueName("3", "铝合金"), new ValueName("4", "PP"),
                new ValueName("5", "PVC"), new ValueName("6", "实木"), new ValueName("7", "铁艺"), new ValueName("8", "ABS"),
                new ValueName("9", "PU"), new ValueName("10", "PE"), new ValueName("11", "树脂"), new ValueName("12", "亚克力"),
                new ValueName("13", "植物编织"), new ValueName("14", "锌合金"), new ValueName("15", "无边"), new ValueName("16", "刨花板"),
                new ValueName("17", "其他")
        ));
        public List<ValueName> shapeList = new ArrayList<>(Arrays.asList(
                new ValueName("1", "圆形"), new ValueName("2", "跑道圆"), new ValueName("3", "方形"), new ValueName("4", "直边圆角"),
                new ValueName("5", "圆角拱形"), new ValueName("6", "直角拱形"), new ValueName("7", "六边形"), new ValueName("8", "冬瓜圆"),
                new ValueName("9", "八边形"), new ValueName("10", "同边圆角"), new ValueName("11", "水滴形"), new ValueName("12", "椭圆"),
                new ValueName("13", "其他异形"), new ValueName("14", "对边圆角"), new ValueName("15", "正反弯异形"), new ValueName("16", "拱形")
        ));
        public List<ValueName> surfaceTechnologyList = new ArrayList<>(Arrays.asList(
                new ValueName("1", "转印"), new ValueName("2", "包覆"), new ValueName("3", "喷漆"), new ValueName("4", "喷塑"),
                new ValueName("5", "氧化"), new ValueName("6", "贴金箔"), new ValueName("7", "毛坯")
        ));
        public List<ValueName> declareFlagList = new ArrayList<>(Arrays.asList(
                new ValueName("1", "PS类"), new ValueName("2", "木制类"), new ValueName("4", "铝合金"), new ValueName("5", "铁艺"), new ValueName("3", "其他")
        ));
    }

    @Data
    public static class Feature {
        public String value = "";
        public String name = "";
        public List<String> productFunList = new ArrayList<>();
        public List<String> processTypeList = new ArrayList<>();
        public List<String> describe = new ArrayList<>();
        // 可选字段（画框、镜框等）
        public List<String> frameTechnologyList = new ArrayList<>();
        public List<String> pictureSourceList = new ArrayList<>();
        public List<String> frameThemeList = new ArrayList<>();
        public List<String> edgeGrindingList = new ArrayList<>();
    }

    private static List<Feature> buildFeatures() {
        List<Feature> list = new ArrayList<>();
        // 0701 相框
        Feature f701 = new Feature();
        f701.value = "0701"; f701.name = "相框";
        f701.productFunList.addAll(Arrays.asList("Tabletop Frame", "Wall Frame", "Poster Frame", "Document Frame", "Shadow Box", "Collage Frame"));
        f701.processTypeList.addAll(Arrays.asList(
                "加边背板相框", "插片钉相框", "旋转扣相框", "瓜子扣相框", "两片玻璃相框", "非标"
        ));
        f701.describe.addAll(Arrays.asList(
                "①加边背板相框", "切割框条——打钉拼框——放置玻璃/PS板/亚克力板——放置卡纸/衬纸——放置衬片——放置背板——打钉固定——粘贴标贴——塑封产品——包装产品",
                "②插片钉相框", "切割框条——打钉拼框——放置玻璃/PS板——放置卡纸/衬纸——放置背板——打插片钉——固定挂具（尺寸≥16*20”使用）——固定包角（尺寸＞16*20”使用）——粘贴标贴——塑封产品——包装产品",
                "③旋转扣相框", "切割框条——打钉拼框——放置玻璃/PS板——放置卡纸/衬纸——放置背板——旋转压片—固定挂具（尺寸≥16*20”使用）——固定包角（尺寸＞16*20”使用）——粘贴标贴——塑封产品——包装产品",
                "④瓜子扣相框", "切割框条——打钉拼框——放置玻璃/PS板——放置卡纸/衬纸——放置衬片——放置背板——打瓜子扣——固定挂具（尺寸≥16*20”使用）——固定包角（尺寸＞16*20”使用）——粘贴标贴——塑封产品——包装产品",
                "⑤两片玻璃相框", "切割框条——打钉拼框——放置玻璃1——粘贴衬纸——放置玻璃2——放垫高框（优先注塑框）——打瓜子扣——固定挂具——粘贴标贴——塑封产品——包装产品"
        ));
        list.add(f701);

        // 0702 画框
        Feature f702 = new Feature();
        f702.value = "0702"; f702.name = "画框";
        f702.productFunList.addAll(Arrays.asList("Framed Art", "Canvas Art with frame", "Canvas Art without frame", "Alternative Wall Decor"));
        f702.frameTechnologyList.add("取自BOM中裱画工艺");
        f702.pictureSourceList.addAll(Arrays.asList("自主研发", "画商", "客供"));
        f702.frameThemeList.add("取自英科美画编号主题");
        list.add(f702);

        // 0703 镜框
        Feature f703 = new Feature();
        f703.value = "0703"; f703.name = "镜框";
        f703.productFunList.addAll(Arrays.asList("Wall Mirror", "Leaner Mirror", "Standing Mirror", "Door Mirror", "Tabletop Mirror", "LED Mirror", "Mirror with Shelf"));
        f703.edgeGrindingList.addAll(Arrays.asList("平面镜", "磨斜边镜"));
        f703.processTypeList.addAll(Arrays.asList("牛皮纸墙镜", "MDF板墙镜", "竖切牛皮纸墙镜", "竖切MDF板墙镜", "撑角镜", "竖切撑角镜", "非标"));
        f703.describe.addAll(Arrays.asList(
                "①牛皮纸墙镜——贴牛皮纸，无背板(备注：可取消部分工序，不可增加工序)",
                "切割框条→打钉拼框→放置镜片→粘贴胶带→打钉固定→打热熔胶→固定三角板、板条→贴牛皮纸→固定挂具→固定护片、包角→检包→塑封产品→包装产品",
                "②MDF板墙镜——有背板，无牛皮纸(备注：可取消部分工序，不可增加工序)",
                "切割框条→打钉拼框→放置镜片→粘贴胶带→打热熔胶→放置衬片/MDF/灰板纸/中空背板→打钉固定→固定三角板、板条→固定挂具→固定护片、包角→检包→塑封产品→包装产品",
                "③竖切牛皮纸墙镜——贴牛皮纸，无背板(备注：可取消部分工序，不可增加工序)",
                "切割框条→打钉拼框→打热熔胶→放置镜片→粘贴胶带→打825胶→贴牛皮纸→固定挂具→固定护片、包角→检包→塑封产品→包装产品",
                "④竖切MDF板墙镜——有背板，无牛皮纸(备注：可取消部分工序，不可增加工序)",
                "切割框条→打钉拼框→打热熔胶→放置镜片→粘贴胶带→打825胶→放置衬片/MDF/灰板纸/中空背板→打钉固定→固定三角板、板条→固定挂具→固定护片、包角→检包→塑封产品→包装产品",
                "⑤撑角镜(备注：可取消部分工序，不可增加工序)",
                "切割框条→打钉拼框→组装撑角→放置镜片→粘贴胶带→打热熔胶→放置衬片/MDF/灰板纸/中空背板→打钉固定→固定撑角→固定包角→检包→塑封产品→包装产品",
                "⑥竖切撑角镜(备注：可取消部分工序，不可增加工序)",
                "切割框条→打钉拼框→组装撑角→打热熔胶→放置镜片→粘贴胶带→打825胶→放置衬片/MDF/灰板纸/中空背板→打钉固定→固定撑角→固定包角→检包→塑封产品→包装产品"
        ));
        list.add(f703);

        // 0704 空框
        Feature f704 = new Feature(); f704.value = "0704"; f704.name = "空框"; list.add(f704);
        // 0705 功能框
        Feature f705 = new Feature(); f705.value = "0705"; f705.name = "功能框";
        f705.productFunList.addAll(Arrays.asList("Chalkboard", "Dry Erase Board", "Corkboard", "Linen Board", "Combination Board"));
        f705.processTypeList.addAll(Arrays.asList("功能框", "非标"));
        f705.describe.addAll(Arrays.asList(
                "①：切割框条→打钉拼框→放置黑白板/麻布板/软木板→打钉固定→固定三角板/板条→贴牛皮纸（可不贴）→固定挂具→固定护片→固定包角→固定配件→粘贴标贴→塑封产品（可不塑封）→包装产品"
        ));
        list.add(f705);
        // 0706 角样
        Feature f706 = new Feature(); f706.value = "0706"; f706.name = "角样"; list.add(f706);
        // 0707 FOB产品
        Feature f707 = new Feature(); f707.value = "0707"; f707.name = "FOB产品";
        f707.productFunList.addAll(Arrays.asList("Mirror Cabinet", "Shelf", "Drawerfront", "Sideboard"));
        list.add(f707);
        // 0709 帆布画
        Feature f709 = new Feature(); f709.value = "0709"; f709.name = "帆布画"; list.add(f709);
        return list;
    }

    private static List<DataExchangeConfig> buildCommonExchangeConfig() {
        return new ArrayList<>(Arrays.asList(
                new DataExchangeConfig("-9999", "cInvDefine12"),
                new DataExchangeConfig("", "cInvDefine2"),
                new DataExchangeConfig("-9999", "cInvDefine13"),
                new DataExchangeConfig("-9999", "cInvDefine14"),
                new DataExchangeConfig("", "cInvDefine6"),
                new DataExchangeConfig("是", "cInvDefine1")
        ));
    }

    // ================= Building =================
    @Data
    public static class Building {
        public int maxLength = 99;
        public String csaComUnitCode = "J00";
        public String pkMeasdoc = "MTR";
        public List<ValueName> productCategoriesList = new ArrayList<>(Arrays.asList(
                new ValueName("1", "墙板"), new ValueName("2", "线条与配件"), new ValueName("3", "户外")
        ));
        public List<ValueName> qualityList = new ArrayList<>(Arrays.asList(
                new ValueName("5001", "PS"), new ValueName("500202", "PVC"), new ValueName("5003", "PE"), new ValueName("5004", "MDF"),
                new ValueName("5005", "铝合金"), new ValueName("5006", "PU")
        ));
        public List<ValueName> productFunList = new ArrayList<>(Arrays.asList(
                new ValueName("1", "平面墙板"), new ValueName("2", "格栅墙板"), new ValueName("2", "格栅收边条"), new ValueName("4", "吸音板"),
                new ValueName("5", "墙面装饰线条"), new ValueName("6", "踢脚线"), new ValueName("7", "地板配件"), new ValueName("8", "灯带线"),
                new ValueName("9", "门窗套线"), new ValueName("10", "顶角线"), new ValueName("11", "吊顶线"), new ValueName("12", "户外家具"),
                new ValueName("13", "户外拼接地板"), new ValueName("14", "户外围栏"), new ValueName("15", "户外墙板"), new ValueName("16", "窗帘杆")
        ));
        public List<ValueName> surfaceTechnologyList = new ArrayList<>(Arrays.asList(
                new ValueName("1", "热转印"), new ValueName("2", "包覆"), new ValueName("3", "喷漆"), new ValueName("4", "平贴"), new ValueName("5", "UV漆"),
                new ValueName("6", "砂光"), new ValueName("7", "喷涂"), new ValueName("8", "氧化"), new ValueName("9", "注塑")
        ));
        public List<ValueName> surfaceStyleList = new ArrayList<>(Arrays.asList(
                new ValueName("1", "黑色"), new ValueName("2", "白色"), new ValueName("3", "纯色"), new ValueName("4", "金属"), new ValueName("5", "木纹"),
                new ValueName("6", "布纹"), new ValueName("7", "石纹"), new ValueName("8", "毛坯")
        ));
        public List<ValueName> applicationScenariosList = new ArrayList<>(Arrays.asList(
                new ValueName("1", "墙面"), new ValueName("2", "顶面"), new ValueName("3", "地面"), new ValueName("4", "户外地面"), new ValueName("5", "户外墙面"),
                new ValueName("6", "户外围栏"), new ValueName("7", "户外家具")
        ));
        public List<DataExchangeConfig> dataExchangeConfig = buildCommonExchangeConfig();
    }

    // ================= Frame =================
    @Data
    public static class Frame {
        public List<DataExchangeConfig> dataExchangeConfig = buildCommonExchangeConfig();
    }

    // ================= Pellet / Other =================
    @Data
    public static class Pellet { }
    @Data
    public static class Other { }

    // ================= Generic ValueName & DataExchangeConfig =================
    @Data
    public static class ValueName {
        public String value;
        public String name;
        public ValueName(String value, String name) { this.value = value; this.name = name; }
    }

    @Data
    public static class DataExchangeConfig {
        public String value;
        public String name;
        public DataExchangeConfig(String value, String name) { this.value = value; this.name = name; }
    }

}
